package com.qqtech.qquan.ad.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qqtech.core.common.enums.YesNoEnum;
import com.qqtech.core.frame.model.Result;
import com.qqtech.core.frame.service.BaseService;
import com.qqtech.qquan.ad.model.AdBase;
import com.qqtech.qquan.ad.model.AdBaseQuery;
import com.qqtech.qquan.ad.model.AdBaseVo;
import com.qqtech.qquan.ad.service.AdBaseService;
import com.qqtech.qquan.sys.enums.SysConst;
import com.qqtech.web.context.BaseWebController;

@Controller
@RequestMapping(value = "/ad/base")
public class AdBaseController extends BaseWebController<AdBase, AdBaseQuery> {
	@Resource
	private AdBaseService adBaseService;
    
	@Override
	protected BaseService<AdBase> getBaseService() {
		return adBaseService;
	}
	
	/**
	 * 列表
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/list")
	@ResponseBody
	public Result list(@RequestBody AdBaseQuery adBaseQuery) {
		Result result = new Result();
		adBaseQuery.setStatus(YesNoEnum.YES.getCode());
		List<AdBaseVo> list=adBaseService.queryList(adBaseQuery);
		result.put("list", list);
		return result;
	}
	
	/**
	 * 详情
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/detail")
	@ResponseBody
	public Result detail(@RequestBody AdBaseQuery adBaseQuery) {
		Result result = new Result();
		AdBaseVo detail=adBaseService.getById(adBaseQuery.getId());
		detail.setImgString(detail.getContentImg(), SysConst.IMG_POSTFIX);
		result.put("detail", detail);
		return result;
	}
}
